We’ve finally arrived at creating our first maps based on the data we imported and cleaned in the previous sessions. The focus on this first session lies on the package “tmap” to create maps.

1

Let’s start super simple. Import our enhanced district data. Create a map with the outline of Germany and one were the borders of the districts are visible. Chose a color of your choice for both maps.

2

In a second step, we want to visualize some information on the German districts contained in the attribute table. Choose the column and create a map of Covid-19 cases per 100,000 inhabitants in Germany. Alternate the map by:

  • add a legend title and change the color palette
  • add a title to the map and change the font color of the title
  • place the legend outside to of the map at the bottom

Assign your map to an object called “covid_map”.

Check the head() of your shapefile. You might to need to rename some of the columns or use the correct names: “cases_per_100k” (abbreviated: "cs__100").

Combine following options with a plus sign:

  • add a legend title and change the color palette: tm_fill(col = "“, title =”“, palette =”") +
  • add a title to the map and change the font color of the title: tm_layout(title = "“, title.color =”") +
  • place the legend outside: tm_legend(legend.outside = T/N, legend.outside.position = "")

If you run “colors()”, R returns the names of all built-in colors.

To assign your map to an object use the arrow “<-”.